package com.chenfan.mcn.extension.convertor;

import org.apache.commons.lang.StringUtils;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * 实体类中属性转换策略
 *
 * @author wulg
 * @date 2021-08-23
 **/
public class PropertyConversionStrategy {

    /**
     * NUll字符串转空处理
     * @param value
     * @return
     */
    public String nullStringAsEmpty(String value){
        return StringUtils.defaultString(value,"");
    }

    /**
     * LocalDateTime转Date
     * @param value
     * @return
     */
    public Date localDateTimeToDate(LocalDateTime value) {
        if(value == null) {
            return null;
        }
        return Date.from(value.atZone(ZoneId.systemDefault()).toInstant());
    }





    /*public String booleanToString(Boolean value) {
        if(value == null) {
            return null;
        }
        return value.booleanValue() ? "是" : "否";
    }*/
}
